<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=request.getContextPath() %>/static/common/plugin/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<style type="text/css">
	#header {
		text-align: center;
		border-bottom: 2px solid black;
	}
	
	.contents {
		font-size:16px;
		font-family: 微软雅黑;
	}
	
	#time {
		color:red;
		border:2px solid lightgray;

	}
</style>
<script type="text/javascript">
	
	//获取总分值数
	var totalMinutes = '${paper.total_minutes}';
	// 把分钟转换为秒
	var seconds = totalMinutes*60;
	// 获取表单元素
	var form;

	function getRemainderTime() {
		form = document.forms[0];
		// 计算小时
		var hours = getTime(Math.floor(seconds/3600));
		// 计算分钟数
		var minutes = getTime(Math.floor((seconds%3600)/60));
		
		// 剩余秒数
		var remainderSecond =  getTime(seconds%60);
		
		document.getElementById("time").innerText = hours+":"+minutes+":"+remainderSecond;
		
		seconds--;
		
		if (seconds<1) {
			
			form.submit();
		}
	}
	
	function getTime(time) {
		
		if (time<10) {
			time = "0"+time;
		}
		
		return time;
	}
	
	// 设置定时器
	setInterval("getRemainderTime()", 1000);
</script>
</head>
<body>
	<form action="${pageContext.request.contextPath }/StudentServlet?command=getAnswer&paperId=${param.paperId}" method="post">
		<div id="header">
			<h2>2016-2017年度考${paper.name }试试卷</h2>
			<h4>考试时间:${paper.total_minutes }分钟</h4>
			<h4>离考试结束还有<span id="time"></span>分钟</h4>
		</div>
		<div id="choice">
			<h4>一、单选题 共${paper.single_option_number }题，每题${paper.single_option_each_point }分</h4>
			<c:forEach items="${choiceList }" var="choice" varStatus="status">
				<span class="contents">${status.count }</span>、${choice.question }<br/>
				<input type="hidden"  value="${choice.id }" name="examId" />
				<input type="radio" value="A-choice" name="${choice.id }" />A、${choice.answer_a }<br/>
				<input type="radio" value="B-choice" name="${choice.id }" />B、${choice.answer_b }<br/>
				<input type="radio" value="C-choice" name="${choice.id }" />C、${choice.answer_c }<br/>
				<input type="radio" value="D-choice" name="${choice.id }" />D、${choice.answer_d }<br/>
				<br/>
			</c:forEach>
		</div>
		<div id="multipleChoice">
			<h4>二、多选题 共${paper.multi_option_number }题，每题${paper.multi_option_each_point }分</h4>
			<c:forEach items="${multipleList }" var="multi" varStatus="status">
				<span class="contents">${status.count }</span>、${multi.question }<br/>
				<input type="hidden" id="multi${multi.id }"  value="${multi.id }" name="examId" />
				<input type="checkbox" value="A-multi" name="${multi.id }" />A、${multi.answer_a }<br/>
				<input type="checkbox" value="B-multi" name="${multi.id }" />B、${multi.answer_b }<br/>
				<input type="checkbox" value="C-multi" name="${multi.id }" />C、${multi.answer_c }<br/>
				<input type="checkbox" value="D-multi" name="${multi.id }" />D、${multi.answer_d }<br/>
				<br/>
			</c:forEach>
		</div>
		<div id="judge">
			<h4>三、判断题 共${paper.judge_number }题，每题${paper.judge_each_point }分</h4>
			<c:forEach items="${judgeList }" var="judge" varStatus="status">
				<span class="contents">${status.count }</span>、${judge.question }
				<input type="hidden"  value="${judge.id }" name="examId" />
				<input type="radio" value="1-judge" name="${judge.id }" />√
				<input type="radio" value="2-judge" name="${judge.id }" />×<br/>
				<br/>
			</c:forEach>
		</div>
		<input type="submit" value="提交试卷" />
	</form>
</body>
</html>